package com.hellobike.haxing.modules.wms.job;

import com.hellobike.haxing.modules.wms.facade.WmsSyncFacade;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@Component
public class DeliveryOrderCreateJob {

    @Autowired
    private WmsSyncFacade wmsSyncFacade;

    @Scheduled(cron = "0 15 22 * * ? ")
    public void execute(){
        log.info("同步订单到Wms定时任务开始");
        Map<String, Object> params = new HashMap<>();
        try {
            Map<String, Object> map = wmsSyncFacade.syncOrderMerge2DO(params);
            Boolean success = (Boolean) map.get("success");
            if(success){
                log.info("同步订单到Wms定时任务完成,{}",map);
            }else {
                log.warn("同步订单到Wms定时任务部分异常,{}",map);
            }
        } catch (Exception e) {
            log.error("同步订单到Wms定时任务异常",e);
        }
    }
}
